package cn.yunhe.services;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import cn.yunhe.dao.IHouseDao;
import cn.yunhe.model.House;
import cn.yunhe.util.SqlSessionFactoryUtil;

/**
 * 
 * @author Administrator
 *
 */
public class HouseServices {
	SqlSession se = SqlSessionFactoryUtil.getSqlSession();
	IHouseDao houseDao = se.getMapper(IHouseDao.class);
	
	/**
	 * 添加住房
	 * @return
	 */
	public boolean addHouse(House house){
		boolean flag = houseDao.addHouse(house);
		se.commit();
		return flag;
	}
	/**
	 * 修改住房
	 * @return
	 */
	public boolean editHouse(House house){
		boolean flag = houseDao.editHouse(house);
		se.commit();
		return flag;
	}
	/**
	 * 删除住房
	 * @return
	 */
	public boolean delhouse(int id){
		boolean flag = houseDao.delhouse(id);
		se.commit();
		return flag;
	}
	/**
	 * 查询所有住房
	 * @return
	 */
	public List<House> getAllHouse(int pageIndex,int pageCount){
		pageIndex = (pageIndex-1)*pageCount;
		return houseDao.getAllHouse(pageIndex,pageCount);
	}
	/**
	 * 获得住房总数
	 * @return
	 */
	public int getHouseCount(){
		return houseDao.getHouseCount();
	}
	
	
}
